Skip to content

refactor(mx_dma): extract common code from core_v1/v2 into core_common#13

Closed
daeyeong-XCENA wants to merge 2 commits into
mainfrom
dylee/refactor/core-common-extraction
Closed

refactor(mx_dma): extract common code from core_v1/v2 into core_common#13
daeyeong-XCENA wants to merge 2 commits into
mainfrom
dylee/refactor/core-common-extraction

Conversation

@daeyeong-XCENA
Copy link
Copy Markdown
Collaborator

PR Summary

  • Extract duplicated submit/complete handler logic from core_v1.c and core_v2.c into shared core_common.c via queue_ops abstraction.

Details

  • Add core_common.c with unified submit_handler and complete_handler using struct queue_ops vtable
  • Refactor core_v1.c and core_v2.c to register hardware-specific ops instead of duplicating handler logic
  • Add struct queue_ops and related declarations to mx_dma.h
  • Update Makefile to include core_common.o
  • Add CLAUDE.md for project documentation

Tests

  • Build verification with make (CXL mode) and make WO_CXL=1 (standalone mode)
  • Runtime validation via userspace DMA transfer tests

Eliminate code duplication between core_v1.c and core_v2.c by extracting
shared logic into core_common.c and unifying submit/complete handlers
through a per-queue operations vtable (struct mx_queue_ops).

Changes:
- Extract descriptor list utilities (mx_get_list_count,
  mx_get_total_desc_count, mx_desc_list_init) to core_common.c.
  The v1/v2 behavioral difference (v2 skips the first SG entry) is
  handled via skip_first/skip_first_entry parameters.
- Extract kthread_stop helper (mx_stop_queue_threads) to core_common.c.
- Add struct mx_queue_ops vtable with is_pushable, push_command,
  post_submit, is_popable, pop_completion, post_complete callbacks.
- Implement unified mx_submit_handler/mx_complete_handler in
  core_common.c that dispatch through the ops vtable.
- Add v1_queue_ops/v2_queue_ops adapter wrappers using container_of
  (safe since common is the first member in both queue structs).
- Remove duplicated submit_handler/complete_handler from both files.
- Add .clang-format to disable auto-formatting for this kernel module.
@daeyeong-XCENA daeyeong-XCENA deleted the dylee/refactor/core-common-extraction branch February 9, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant